import java.util.*;

import sdljava.SDLException;
import sdljava.event.SDLEvent;

public class Construction {
	private Vector<ConstructionLocations> sites;
	private ConstructionLocations currentSite;
	private GameWindow gameWindow;
	private Boolean done = false;
	
	public Construction(GameWindow gameWindow) throws SDLException{
		this.gameWindow = gameWindow;
		sites = new Vector<ConstructionLocations>();
		populateLVector();
		currentSite = sites.get(0);
	}
	public void populateLVector() throws SDLException{
		ConstructionLocations base = new Base(gameWindow, "bitmaps/base_construction_button.bmp");
		ConstructionLocations wall = new Wall(gameWindow, "bitmaps/wall_construction_button.bmp");
		ConstructionLocations roof = new Roof(gameWindow, "bitmaps/roof_construction_buttons.bmp");
		
		sites.add(base);
		sites.add(wall);
		sites.add(roof);
	}
	
	public Vector<ConstructionLocations> getSites(){
		return sites;
	}
	public void handleEvent(SDLEvent event)throws SDLException{
		currentSite.handleEvent(event);
		if(currentSite.changeLocation == 1){
			if(sites.indexOf(currentSite) != 2){
				currentSite = sites.get(sites.indexOf(currentSite)+1);
				currentSite.show();
			}
			else{
				done = true;
			}
		}
		else if(currentSite.changeLocation == 2){
			done = true;
		}
	}
	public Boolean getDone(){
		return done;
	}
	public void resetDone(){
		done = false;
	}
	public Boolean check(){
		if(sites.get(0).check() && sites.get(1).check() && sites.get(2).check()){
			return true;
		}
		else{
			return false;
		}
	}
	public ConstructionLocations getCurrentSite(){
		return currentSite;
	}
	public void setCurrentSite(int relocate){
		this.currentSite = sites.get(relocate);
	}
}
